package businesslogic.courseselectionbl.Strategy;

import businesslogic.courseselectionbl.SelectMessage;
import businesslogic.courseselectionbl.test.Debug;

import po.CourseClassification;
import po.CourseSelectionPO;
import po.LessonPO;
import po.StudentPO;

public class CrossSelectStrategy extends PreSelectStrategy implements SelectStrategy {

	
	public CrossSelectStrategy(CourseClassification type, int maxCourseNum) {
		this.type = type;
		if(maxCourseNum >= 0)
			this.maxCourseNum = maxCourseNum;
	}
	
	
	public boolean canSelect(LessonPO lesson, StudentPO student) {
		
		if(!super.canSelect(lesson, student))
			return false;
		CourseSelectionPO temp = new CourseSelectionPO(lesson, student, 0 , false, false);
		if(isFine(temp)) {
			//Debug.output("canselsct");
			return true;
		}
		Debug.setSelectMessage(SelectMessage.INSTITUTE_DISABLE);
		return false;
	}
	
	public boolean isFine(CourseSelectionPO record) {
		LessonPO lesson = record.getLessonPO();
		StudentPO student = record.getStudentPO();
		//Debug.output(lesson.getInstitute()==null);
		return (!lesson.getInstitute().equals(student.getInstitute())) 
				&& lesson.getCourseClassification().equals(CourseClassification.ZHUANYEKE);
	}
	
	
	
}
